package com.vcms.cms.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Tag entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tag", catalog = "vcms_0.1")
public class Tag implements java.io.Serializable {

	// Fields

	private Integer tagId;
	private String tagName;
	private Integer refCount;
	private Set<Content> contents = new HashSet<Content>(0);

	// Constructors

	/** default constructor */
	public Tag() {
	}

	/** full constructor */
	public Tag(String tagName, Integer refCount, Set<Content> contents) {
		this.tagName = tagName;
		this.refCount = refCount;
		this.contents = contents;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "tagId", unique = true, nullable = false)
	public Integer getTagId() {
		return this.tagId;
	}

	public void setTagId(Integer tagId) {
		this.tagId = tagId;
	}

	@Column(name = "tagName", length = 50)
	public String getTagName() {
		return this.tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	@Column(name = "refCount")
	public Integer getRefCount() {
		return this.refCount;
	}

	public void setRefCount(Integer refCount) {
		this.refCount = refCount;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "content_tag", catalog = "vcms_0.1", joinColumns = { @JoinColumn(name = "tagId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "contentId", nullable = false, updatable = false) })
	public Set<Content> getContents() {
		return this.contents;
	}

	public void setContents(Set<Content> contents) {
		this.contents = contents;
	}

}